import { type IRes, chatHttp } from '@/utils/request';
import type { IFriendItem, IAddFriendParams, IGroupItem, IAddGroupParams } from './type';

// 模糊查询符合条件的用户
export const getFriendList = (username: string) =>
	chatHttp.get<IRes<IFriendItem[]>>({
		url: `/friend/search_user?username=${username}`
	});

// 加好友
export const addFriend = (data: IAddFriendParams) =>
	chatHttp.post<IRes>({
		url: '/friend/add_friend',
		data
	});

// 模糊查询符合条件的群
export const getGroupList = (group_name: string) =>
	chatHttp.get<IRes<IGroupItem[]>>({
		url: `/group/search_group?name=${group_name}`
	});
// 加群

export const addGroup = (data: IAddGroupParams) =>
	chatHttp.post<IRes>({
		url: '/group/add_group',
		data
	});
